<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="app.engine.solucoes.request.beans.*,java.util.*"
	errorPage="errorw.jsp"%>
<jsp:useBean id="usuario" class="app.engine.solucoes.request.beans.Usuario" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.text.SimpleDateFormat"%><html>
<head>
	<script type="text/javascript" src="/javascript/script.js"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title><%=usuario.getNomeUsuario() != null ? usuario.getNomeUsuario() : ""%> - [Perguntas]</title>
</head>
<body>
<%
	if (usuario.getId() == null)
		response.sendRedirect("/");
%>
	<% List<Pergunta> perguntas  = (List<Pergunta>) request.getAttribute("perguntas"); %>
	<%SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); %>
	<form name="menu" action="faqtool" method="post">
		<input type="hidden" name="cmd" value="">
		<table bgcolor="tan" border="1" align="center" cellpadding="10" cellspacing="0">
			<tr>
			   <th colspan="6">Manutenção de FAQ</th>
			</tr>
			<tr>
				<td align="center">&nbsp;</td>
				<td align="center">Descrição</td>
				<td align="center">Data Criação</td>
				<td align="center">Login Usuario</td>
				<td align="center">Aprovada</td>
			</tr>
             <% for(Pergunta pergunta : perguntas) { %>
                 <tr>
                    <td align="center"><input type="radio" name="idPergunta" value=<%= pergunta.getId() %> /></td>
                    <td><%= pergunta.getTxtPergunta() != null ? pergunta.getTxtPergunta() : "&nbsp;" %></td>
                    
                    <td><%= pergunta.getDataCriacao() != null ? sdf.format(pergunta.getDataCriacao()) : "&nbsp;"%></td>
                    <td align="center"><%= pergunta.getUsuarioPergunta() != null ? pergunta.getUsuarioPergunta() : "&nbsp;" %></td>
                    <td align="center"><%= pergunta.getAprovada() != null && pergunta.getAprovada() ? "Sim" : "Não" %></td>
                 </tr>
             <% } %>
			<tr>
			   <td colspan="6" align="center">
			      <input type="submit" value="Voltar" onClick="document.menu.cmd.value='abort'" />
			      <input type="submit" value="Editar FAQ" onClick="document.menu.cmd.value='update'" />
			      <input type="submit" value="Excluir FAQ" onClick="document.menu.cmd.value='remove-question'" />
			      <input type="submit" value="Sair" onClick="setCmd('exit')" />
			   </td>
			</tr>
            <% if (request.getAttribute("faqtool.msg") != null) { %>
			<tr>
				<td colspan="6" bgcolor="white">
					<font size="-1" color="<%=request.getAttribute("corFonte") != null ? request.getAttribute("corFonte") : "black"%>"> 
						<i><%=request.getAttribute("faqtool.msg")%></i>
					</font>
				</td>
			</tr>
			<%} %>
        </table>
	</form>
</body>
</html>
